<?php
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2019/9/17
 * Time: 13:58
 */
namespace app\apiteacher\controller;
use think\Db;
class Me extends Base {
    /**
     * 异地登录验证
     * @return string
     */
    public function __construct()
    {
        $user_id2 = input('user_id');
        $time = input('time');
        $value = input('value');
        $reqKey = input('reqKey');
        $auth = $this->checkAll($user_id2,$time,$value,$reqKey);
        if($auth == 112){
            echo json_encode(['status'=>301,'msg'=>$this->otherLogin]);
            exit;
        }elseif($auth == 110){
            echo json_encode(['status' => 302, 'msg' => $this->frost]);
            exit;
        }elseif($auth == 2111){
            echo json_encode(['status' => 303, 'msg' => $this->del]);
            exit;
        }
    }
    /****
     * @return \think\response\Json
     * 公开课
     */
    public function classes(){
        extract(input());
//        $user_id = 10;
        $page = input('param.page')?input('param.page'):1;
        $num = 10;
        $limit = $page-1;
        $where['public_teacher_id'] = $user_id;
        $res = Db::table('up_public_class')->where($where)
            ->limit($num*$limit,$num)
            ->order('public_is_top asc, public_time desc')
            ->select();
        foreach ($res as $key=>&$vo){
            $count = Db::table('up_public_apply')->where('apply_public_id',$vo['public_id'])->count();
            $vo['num'] = $count;
            $subject_name = Db::table('up_subject')->where('subject_id',$vo['public_subject'])->value('subject_name');
            $vo['subject_name'] = $subject_name;
        }
        return  json(array('status'=>200,'msg'=>$res));
    }

     public function oneToOne(){
         extract(input());
//         $user_id = 2;
         $page = input('param.page')?input('param.page'):1;
         $num = 10;
         $limit = $page-1;
         $where['a.one_teacher_id'] = $user_id;
         $where['a.one_status'] = 4;
         $res = Db::table('up_one_to_one')->alias('a')
             ->join('up_u_user uuu','uuu.user_id = a.one_student_id','left')
             ->field('a.*,uuu.user_username')
             ->where($where)
             ->limit($num*$limit,$num)
             ->select();
         return  json(array('status'=>200,'msg'=>$res));
     }
}